<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Excel去重工具</title>
</head>
<body>
<h2>Excel去重工具</h2>
<form id="uploadForm" enctype="multipart/form-data">
    <input type="file" id="fileInput" accept=".xlsx,.xls" required>
    <button type="submit">上传并去重</button>
</form>

<div id="result"></div>

<script>
    document.getElementById('uploadForm').addEventListener('submit', async (e) => {
        e.preventDefault();

        const fileInput = document.getElementById('fileInput');
        const formData = new FormData();
        formData.append('file', fileInput.files[0]);

        try {
            const response = await fetch('/excel/deduplicate', {
                method: 'POST',
                body: formData
            });

            const result = await response.json();
            document.getElementById('result').innerHTML =
                `<pre>${JSON.stringify(result, null, 2)}</pre>`;
        } catch (error) {
            document.getElementById('result').innerHTML =
                `<p style="color: red;">错误: ${error.message}</p>`;
        }
    });
</script>
</body>
</html>